package com.oocl.zero.task0710.property.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Map;

import com.oocl.zero.task0710.property.entity.Customer;
import com.oocl.zero.task0710.property.filter.CustomerFilter;
import com.oocl.zero.task0710.property.out.Printer;

public class CustomerUtil {
	public static Customer getCustomerInstanceBy(Map<Integer, String> map){
		Customer c=new Customer();
		//8 john john@163.com 			 1999-10-2
		try {
			c.setId( Integer.parseInt(map.get(1)) );
			c.setName( map.get(2) );
			c.setEmail( map.get(3) );
			c.setGender( "true".equals(map.get(4)) );
			long time = new SimpleDateFormat( CustomerFilter.DATE_FORMAT ).parse( map.get(5) ).getTime();
			c.setBirthday(time);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
//			e.printStackTrace();
			Printer.print("date input err,need to be checked");
			return null;
		}
		return c;
	}
}
